#include <ros/ros.h>
#include <sensor_msgs/PointCloud2.h>

ros::Publisher pointcloud_pub;
std::string sub_topic_;
std::string pub_topic_;

void pointCloudCallback(const sensor_msgs::PointCloud2::ConstPtr& msg)
{
    // 修改点云数据帧
    sensor_msgs::PointCloud2 modified_cloud = *msg;
    modified_cloud.header.frame_id = pub_topic_;
    ROS_INFO("OK");
    // 发布修改后的点云数据
    pointcloud_pub.publish(modified_cloud);
}

int main(int argc, char** argv)
{
    // 初始化ROS节点
    setlocale(LC_ALL,"");
    ros::init(argc, argv, "ppk");
    ROS_INFO("初始化");

    // 创建ROS节点句柄
    ros::NodeHandle nh;
    //...

    nh.getParam("sub_topic_", sub_topic_);
      nh.getParam("pub_topic_", pub_topic_);

    // 创建发布器
    pointcloud_pub = nh.advertise<sensor_msgs::PointCloud2>(pub_topic_, 10);

    // 创建订阅器
    ros::Subscriber pointcloud_sub = nh.subscribe(sub_topic_, 10, &pointCloudCallback);

    // 循环等待回调函数
    ros::spin();

    return 0;
}